package com.yanqu.road.dataHelper.action.userCenterScript;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dataHelper.manager.BaseMgr;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ActivityScript extends BaseMgr {


    public ActivityScript(){

    }

    public int getFirstActivityId(long serverId,int type,int childType) {
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "select * from t_s_activity_main WHERE serverId = ? AND type = ? AND childType = ? ORDER BY beginShowTime ASC LIMIT 1 ";
        try {
            getDb().setConnName(DbNameStrategy.getServerDb());
            call = getDb().getConnection().prepareCall(sql);
            call.setLong(1, serverId);
            call.setLong(2, type);
            call.setLong(3, childType);
            rs = call.executeQuery();
            while (rs.next()) {
                return rs.getInt("activityId");
            }
        } catch (SQLException ex) {
            logger.error("异常错误", ex);
        } finally {
            getDb().closeConnection(call, null);
        }
        return 0;
    }


}
